/**
 * Copyright 2012
 * VAN
 */
package vaidyaa.algorithms.sorting;

/**
 * @author vaidyaa
 * 
 */
public class SortingCommons {
	
	/**
	 * For Ascending Order if x < y return True
	 * For Descending Order if x > y return True
	 * 
	 * @param x
	 * @param y
	 * @param order True for descending order, False for Ascending order
	 * @return
	 */
	public static boolean compare(Integer x, Integer y, boolean order) {
		if (order && x < y) {
			return true;
		} else if (!order && x > y) {
			return true;
		}
		return false;
	}

	public static void printArray(Integer array[]) {
		StringBuilder builder = new StringBuilder();
		for (int i = 0; i < array.length; i++) {
			builder.append("," + array[i]);
		}
		System.out.println(builder.toString().replaceFirst(",", ""));
	}
	
	public static void swap (Integer array[], int x, int y) {
		Integer temp = array[x];
		array[x] = array[y];
		array[y] = temp;
	}
}
